import VueRouter from 'vue-router'
import routes from './config/routes'
import env from './config/env'
import common from './utils/common'

const router = new VueRouter({
  //mode: 'history',
  base: __dirname,
  routes: routes
})

router.afterEach((to, from) => {
	/*if(to.name) {
		window.document.title = to.name
	}*/
})

//登录拦截
/*router.beforeEach((to, from, next) => {
	if(!localStorage.ticket){
		var back = top.location.href;
		var url = common.getApiPrefix()+"/api/weixin/mp/checkOauth2?url="+encodeURIComponent(back)+"&r="+$.now();
		common.doPost(url,{},function(data){
			if(data.authorizeUrl){
				window.location.href = data.authorizeUrl;
				return;
			}else{
				localStorage.setItem("menber", data.menber);
				localStorage.setItem("ticket", data.ticket);
			}
		},function(){
			
		},true);
  	
	}
 	next();
})*/

export default router